﻿package mortal.game.view.palyer.view
{
    import com.mui.controls.*;
    import com.mui.core.*;
    import mortal.game.cache.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.palyer.data.*;

    public class PlayerTabCellRender extends GCellRenderer
    {
        private var _title:GImageBitmap;
        private var _activitiesIcon:GImageBitmap;
        private var _tabBtn:GLoadedButton;

        public function PlayerTabCellRender()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._tabBtn = UIFactory.gLoadedButton(ImagesConst.PlayerTab_upSkin, 5, 0, 80, 43, this);
            this._tabBtn.setStyle("disabledSkin", GlobalClass.getBitmap(ImagesConst.PlayerTab_disableSkin));
            this._tabBtn.drawNow();
            this._title = UIFactory.gImageBitmap("", 0, 0, null, this.resetPos);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._tabBtn.dispose(param1);
            this._tabBtn = null;
            this._title.dispose(param1);
            this._title = null;
            if (this._activitiesIcon)
            {
                this._activitiesIcon.dispose(param1);
                this._activitiesIcon = null;
            }
            super.disposeImpl(param1);
            return;
        }// end function

        override public function set selected(param1:Boolean) : void
        {
            super.selected = param1;
            if (param1)
            {
                this._tabBtn.enabled = false;
            }
            else
            {
                this._tabBtn.enabled = true;
            }
            this._tabBtn.drawNow();
            return;
        }// end function

        private function resetPos() : void
        {
            if (this.isDisposed)
            {
                return;
            }
            this._title.x = (this.width - this._title.width) * 0.5 + 10;
            this._title.y = (this.height - this._title.height) * 0.5;
            this.addChild(this._title);
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            super.data = param1;
            var _loc_2:* = param1 as PlayerTabData;
            this._title.imgUrl = "playerTabName_" + _loc_2.tabType + ".png";
            this.resetSkinByActiveName(_loc_2.tabName);
            return;
        }// end function

        private function resetSkinByActiveName(param1:String) : void
        {
            if (param1 == Cache.instance.openServerSevenDay.getTargetTypeName())
            {
                if (this._activitiesIcon == null)
                {
                    this._activitiesIcon = UIFactory.gImageBitmap(ImagesConst.PlayerTabActivitesIcon, 5, 0, this);
                }
            }
            else if (this._activitiesIcon)
            {
                this._activitiesIcon.dispose();
                this._activitiesIcon = null;
            }
            return;
        }// end function

    }
}
